#-*- coding:utf-8 -*-
'''
Created on 19.Şub.2010

@author: Metehan
'''
import sys, os
from hashlib import sha1

VERSION = "0.1 Alpha"

mesaj = u"""<html>
        Lisans: GPL v3<br>
        Sürüm: %s<br>
        <b>Odun</b> © 2010<br>
        <b>Kodlayanlar:</b><br>
        Aşkın Yollu - <a href="mailto:askin@askin.ws">askin@askin.ws</a><br>
        Erdem Artan - <a href="mailto:badibere@gmail.com">badibere@gmail.com</a><br>
        Metehan Özbek - <a href="mailto:metehan@istanbul.com">metehan@istanbul.com</a><br>
        <b>Simge:</b><br>
        Yasin Özcan - <a href="mailto:hamfindik@gmail.com">hamfindik@gmail.com</a><br>
        <br>Proje Sayfası:
        <a href='http://code.google.com/p/pisidown'>http://code.google.com/p/pisidown</a>
        </html>
        """%VERSION

def byte(x):
    if x >= 1024 and x <= 1024*1024:
        x = str(round(x/1024.0, 2)) + " KB"
        return x
    elif x >= 1024*1024:
        x = str(round(x/1024/1024.0, 2)) + " MB"
        return x
    elif x < 1024:
        x = str(x) + "byte"
        return x

def html_yaz(liste):
    yaz = open("hatalipaketler.html","w")
    yaz.write("<html>")
    for i in liste:
        yaz.write("\t<a href='%s'>%s</a>"%(i[1],i[0]))
    yaz.write("</html>")
    yaz.close()

def dogrulama(pisiname, hash):
    if sys.platform == "win32":
        pisi = open(os.getcwd()+"\\packages\\"+pisiname,"rb")
    else:
        pisi = open(os.getcwd()+"/packages/"+pisiname,"rb")
    pisihash = sha1(pisi.read()).hexdigest()
    print pisihash, hash
    if hash == pisihash: return True
    else: False